﻿using MySql.Data.MySqlClient;
using NB.MGJ.FrameWork;
using NB.MGJ.Model;
using NB.MGJ.Model.AntiFake;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NB.MGJ.Service.Origins
{
    

  public  class OriginsSearchService
    {
      public BaseRepository _base = new BaseRepository();
      #region 分页数据显示
      public PagedList<CodeLog> GetQueryCodeService(ref PagerModel pager, string ecode)
      {
          pager.FldName = @"*";
          pager.TblName = @"( SELECT Fw_SCode,a.ID,b.Fw_Code,Valid,QueryTime,QueryType,QueryProvince,QueryCity,ProductId,QueryIp,EnterpriseName,EnterpriseID  FROM nblogmain.`codelog" + ecode + "` b LEFT JOIN organization_enterprise a on a.ID=b.EnterpriseId ) s";
          if (string.IsNullOrEmpty(pager.FldSort) || pager.FldSort == " ")
              pager.FldSort = " s.QueryTime desc ";
          MySqlParameter[] parameters = _base.SqParameterRefactor(ref pager);
          IEnumerable<CodeLog> resultList = _base.ExecuteStoredProcedureCollection<CodeLog>("Common_PageList", parameters);
          return new PagedList<CodeLog>(resultList.ToList(), pager.Page, pager.PageSize, 1, Convert.ToInt32(parameters[6].Value));
      }
      #endregion
    }
}
